var menu1 = document.getElementById("menu1");//CPU型号
var menu2 = document.getElementById("menu2");//CPU主频
var menu3 = document.getElementById("menu3");//前置摄像头
var menu4 = document.getElementById("menu4");//屏幕分辨率
var menu5 = document.getElementById("menu5");//存储容量
var menu6 = document.getElementById("menu6");//机身厚度
var menu7 = document.getElementById("menu7");//网络类型
var showmenu1 = document.getElementById("show-menu1");//显示CPU型号
var showmenu2 = document.getElementById("show-menu2");//显示CPU主频
var showmenu3 = document.getElementById("show-menu3");//显示前置摄像头
var showmenu4 = document.getElementById("show-menu4");//显示屏幕分辨率
var showmenu5 = document.getElementById("show-menu5");//显示存储容量
var showmenu6 = document.getElementById("show-menu6");//机身厚度
var showmenu7 = document.getElementById("show-menu7");//网络类型


$(function(){
    $("#result-all").addClass("current");
    $(".order-list").find("a").click(function(f){
        $(".order-list a").removeClass("current");
        $(this).addClass("current");
    })
    $(".type-list").find("a").click(function(f){
        $(".type-list a").removeClass("current");
        $(this).addClass("current");
    })
    $(".mchoice").click(function(){
        var $choice = $(this).find('i');
        if($choice.is(":visible")){
            $choice.hide();
        }else{
            $choice.show();
        }
    })

})
//cpu型号
menu1.onmouseover = function () {
    showmenu1.style.display = "block";
}
showmenu1.onmouseover = function () {
    showmenu1.style.display = "block";
}
showmenu1.onmouseout = function () {
    showmenu1.style.display = "none";
}
menu1.onmouseout = function () {
    showmenu1.style.display = "none";
}
//cpu主频
menu2.onmouseover = function () {
    showmenu2.style.display = "block";
}
showmenu2.onmouseover = function () {
    showmenu2.style.display = "block";
}
showmenu2.onmouseout = function () {
    showmenu2.style.display = "none";
}
menu2.onmouseout = function () {
    showmenu2.style.display = "none";
}
//前置摄像头
menu3.onmouseover = function () {
    showmenu3.style.display = "block";
}
showmenu3.onmouseover = function () {
    showmenu3.style.display = "block";
}
showmenu3.onmouseout = function () {
    showmenu3.style.display = "none";
}
menu3.onmouseout = function () {
    showmenu3.style.display = "none";
}
//屏幕分辨率
menu4.onmouseover = function () {
    showmenu4.style.display = "block";
}
showmenu4.onmouseover = function () {
    showmenu4.style.display = "block";
}
showmenu4.onmouseout = function () {
    showmenu4.style.display = "none";
}
menu4.onmouseout = function () {
    showmenu4.style.display = "none";
}
//存储容量
menu5.onmouseover = function () {
    showmenu5.style.display = "block";
}
showmenu5.onmouseover = function () {
    showmenu5.style.display = "block";
}
showmenu5.onmouseout = function () {
    showmenu5.style.display = "none";
}
menu5.onmouseout = function () {
    showmenu5.style.display = "none";
}
//机身厚度
menu6.onmouseover = function () {
    showmenu6.style.display = "block";
}
showmenu6.onmouseover = function () {
    showmenu6.style.display = "block";
}
showmenu6.onmouseout = function () {
    showmenu6.style.display = "none";
}
menu6.onmouseout = function () {
    showmenu6.style.display = "none";
}
//网络类型
menu7.onmouseover = function () {
    showmenu7.style.display = "block";
}
showmenu7.onmouseover = function () {
    showmenu7.style.display = "block";
}
showmenu7.onmouseout = function () {
    showmenu7.style.display = "none";
}
menu7.onmouseout = function () {
    showmenu7.style.display = "none";
}

var recommend_item = document.querySelectorAll(".recommend-item"),
    swiper_wrapper = document.querySelector(".swiper-wrapper"),
    btn_left = document.querySelector(".swiper-controls .control-left"),
    btn_right = document.querySelector(".swiper-controls .control-right"),
    iNow = 0, //记录当前位置，每4个一组
    count = Math.ceil(8 / 3) - 1, //最大位置下标
    timers = null;
//动态生成ul的宽
var swiperLiWidth = recommend_item[0].offsetWidth +9;
swiper_wrapper.style.width = swiperLiWidth * (recommend_item.length + 1) + "px";
btn_right.onclick = function() {
    clearInterval(timers);
    iNow++;
    // 设置index的范围
    iNow = iNow >= count ? count : iNow;
    tab();
}
btn_left.onclick = function() {
    clearInterval(timers);
    iNow--;
    // 设置index的范围
    iNow = iNow <= 0 ? 0 : iNow;
    tab();
}
tab(); //先调用一次，让箭头样式先改变

function tab() {
    //设值箭头样式
    iNow == 0 ? btn_left.classList.add("swiper-button-disabled") : btn_left.classList.remove("swiper-button-disabled");
    iNow == count ? btn_right.classList.add("swiper-button-disabled") : btn_right.classList.remove("swiper-button-disabled");
    //移动的距离
    var iTarget = iNow == count ? -swiperLiWidth * 3 * 2 - swiperLiWidth : -swiperLiWidth * 3 * iNow;
    swiper_wrapper.style.transitionDuration = "1000ms";
    swiper_wrapper.style.transform = 'translate3d(' + iTarget + "px" + ' ,0,0)';
}